const Handlers = require('./handlers')
const Joi = require('joi')

let internals = {}

internals.endpoints = [
  {
    method: 'GET',
    path: '/recording/{id}',
    handler: Handlers.Get,
    config: {
      tags: ['api'],
      description: 'Get recording by id',
      validate: {
        params: {
          _id: Joi.string().required()
        },
      }
    }
  },
  {
    method: 'GET',
    path: '/recording/list/{session3rd}/{start?}',
    handler: Handlers.GetList,
    config: {
      tags: ['api'],
      description: 'Get recording list by openid',
      validate: {
        params: {
          session3rd: Joi.string().required(),
          start: Joi.date()
        },
      }
    }
  },
  {
    method: 'POST',
    path: '/recording',
    handler: Handlers.Post,
    config: {
      tags: ['api'],
      validate: {
        payload: {
          session3rd: Joi.string().required(),
          title: Joi.string(),
          recordTime: Joi.number(),
          tempFilePath: Joi.string(),
          upload: Joi.boolean()
        }
      }
    }
  },
  {
    method: 'PUT',
    path: '/recording',
    handler: Handlers.Put,
    config: {
      tags: ['api'],
      validate: {
        payload: {
          _id: Joi.string().required(),
          session3rd: Joi.string().required(),
          title: Joi.string(),
          recordTime: Joi.number(),
          tempFilePath: Joi.string(),
          upload: Joi.boolean(),
          openid: Joi.optional(),
          createTime: Joi.optional(),
          createTimeHum: Joi.optional(),
          recordTimeHum: Joi.optional(),
          select: Joi.optional(),
          __v: Joi.optional()
        }
      }
    }
  },
  {
    method: 'DELETE',
    path: '/recording',
    handler: Handlers.Delete,
    config: {
      tags: ['api'],
      validate: {
        payload: {
          _id: Joi.string().required(),
          session3rd: Joi.string().required()
        }
      }
    }
  }
];

module.exports = internals;
